#include <iostream>
#include <memory>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <map>
#include <time.h>
#include <vector>

#include "src/cpp/card.cpp"
#include "src/cpp/deck.cpp"
#include "src/cpp/userstate.cpp"
#include "src/cpp/deckparser.cpp"
#include "src/cpp/cardprovider.cpp"
#include "src/cpp/simulatormanager.cpp"

using namespace std;
using namespace mtga;

int main(void) {
	cout << "MTG Deck Analyzer" << endl;
	cout << "Creating card data base" << endl;

	srand(time(NULL));

	/* probando
	Card* card = new Card("Tarmo", 2, "1G");
	card->getCardTypes()->insert(CardType::Creature);
	cout << "Size: " << card->getCardTypes().size() << endl;
	cout << "1: " << card->isCardType(CardType::Creature) << endl;
	cout << "2: " << card->isCardType(CardType::Artifact) << endl;
	*/

	auto_ptr<CardProvider> cardProvider(new CardProvider());
	auto_ptr<DeckParser> deckParser(new DeckParser(cardProvider.get()));
	auto_ptr<Deck> deck(new Deck("Bug Midrange"));
	auto_ptr<UserState> userState(new UserState(deck.get()));
	auto_ptr<SimulatorManager> simulatorManager(new SimulatorManager(userState.get()));

	cardProvider.get()->loadCards();
	deckParser->loadFromFile(deck.get(), "MTGO", "resources/bug-midrange.dec");

	string option;
	do {
		cout << "Option: ";
		cin >> option;
		if (option.compare("test") == 0) {
			simulatorManager.get()->init();
		} else {
			cout << "Invalid option" << endl;
		}
	} while (option.compare("exit") != 0);

	cout << "Application stop" << endl;
	return 0;
}

